const files = [
  {
    name: "xxx.zip",
  },
  {
    name: "xxx.webp",
  },
];

function filterFiles(files, correctName) {
  return files.filter((files) => {
    const index = files.name.lastIndexOf(".");
    const name = files.name.slice(index);
    return correctName.includes(name);
  });
}

/**
 * 在文件数组中得到所有的图片文件
 * @param {*} files
 * @returns
 */
function getImgFiles(files) {
  const correctName = [".gif", ".bmp", ".webp", ".png", ".jpg", ",jpeg"];
  const data = filterFiles(files, correctName);
  return data;
}

getImgFiles(files);
